package com.newzqxq.koalamoney.ui.fragment;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.newzqxq.koalamoney.R;
import com.newzqxq.koalamoney.common.BaseFragment;
import com.newzqxq.koalamoney.common.Params;
import com.newzqxq.koalamoney.ui.adapter.MyViewPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 理财fragment
 * Created by ZQXQ-Developer on 2017/7/13.
 */

public class MoneyFragment extends BaseFragment {

    @BindView(R.id.tabLayout)
    TabLayout mTabLayout;
    @BindView(R.id.viewPager)
    ViewPager mViewPager;

    MyViewPagerAdapter adapter;
    private String[] titles = new String[]{"7日定投", "14日定投"};
    private String[] titlesCode = new String[]{"seven", "fourteen"};

    @Override
    protected View initView(LayoutInflater inflater, ViewGroup container) {
        return inflater.inflate(R.layout.fragment_money, null);
    }

    @Override
    protected void initData() {
        List<BaseFragment> fragments = new ArrayList<>();
        for (int i = 0; i < titles.length; i++) {
            AutoPlanFragment fragment = new AutoPlanFragment();
            Bundle bundle = new Bundle();
            bundle.putString(Params.DATA, titlesCode[i]);
            fragment.setArguments(bundle);
            fragments.add(fragment);
        }
        adapter = new MyViewPagerAdapter(getChildFragmentManager(), fragments, titles);
        mViewPager.setAdapter(adapter);
        mViewPager.setOffscreenPageLimit(titles.length);
        mTabLayout.setupWithViewPager(mViewPager);
    }

}
